<template>
  <div class="contain">
    <div class="header">
      <div class="header-box">
        <div class="header-l">
          <van-icon name="arrow-left" />
          <span @click="backTo">返回</span>
        </div>

        <h2 class="header-m">专题精选</h2>
        <div></div>
      </div>
    </div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <div>
        <div v-for="item in list" :key="item.id" class="newGoods">
          <ul class="newGoodsBox">
            <li v-for="el in item" :key="el.id" class="newGoods-item" @click="topList(el.id)">
              <img class="img" :src="el.scene_pic_url" alt="" />
              <div class="new-txt">
                <div class="newGoods-name">
                  <span>{{ el.title }}</span>
                </div>
                <div class="newGoods-brief">
                  <span> {{ el.subtitle }}</span>
                </div>
                <div class="newGoods-price">
                  <span>${{ el.price_info }}起</span>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </van-list>
  </div>
</template>

<script>
import { start } from "@/api/topic";

export default {
  name: "topic",
  data() {
    return {
      list: [],
      page: 1,
      loading: false,
      finished: false,
    };
  },
  mounted() {
    start();
  },
  methods: {
    backTo(){
      this.$router.back()
    },
    onLoad() {
      // 异步更新数据

      start({
        page: this.page,
      }).then((res) => {
        console.log(res);
        this.list.push(res.data);
        

        this.loading = false;
        this.page++;
        console.log(this.list);

        // 数据全部加载完成
        if (this.page >res.total) {
          this.finished = true;
        }
      }, 1000);

      // 加载状态结束
    },
    topList(id){
      console.log(id);
      this.$router.push({path:'/topic/topList',query:{id:id}})
    }
  },
};
</script>


<style scoped lang="scss" >
@import "./scss/index.scss";
</style>>

